package com.geodroid.action;

import java.util.ArrayList;

import android.graphics.RectF;
import android.util.Log;

import com.geodroid.common.kernel.geos.GeoElement;
import com.geodroid.euclidian.Drawable;
import com.geodroid.euclidian.EuclidianView;

public class ActionMove extends Action {


	
	private static final String TAG = "ActionMove";
	/*to move objects*/


	public ActionMove(boolean isStarted, int nbClicked, ArrayList <Drawable> draSel) {
		super(isStarted, nbClicked, draSel);
		// TODO Auto-generated constructor stub
	}



	public ActionMove(int nbC) {
		super(nbC) ;  
	}


	
	/* (non-Javadoc)
	 * @see com.geodroid.action.Action#process(int, float, float, java.util.ArrayList)
	 */
	@Override
	public void process(RectF touchedArea, EuclidianView view) {
			Log.d(TAG,"processMove") ; 
			float ux = touchedArea.centerX()-oldTouchedArea.centerX() ; 
			float uy = touchedArea.centerY()-oldTouchedArea.centerY() ;
			draSel.get(0).translate(ux, uy) ;
			Log.d(TAG,"/processMove") ; 
	}

	@Override
	public boolean validate(Drawable d) {
		GeoElement geo = d.getGeo() ; 
		return 	geo.isMoveable() ;
	}



	/* (non-Javadoc)
	 * @see com.geodroid.action.Action#processMove(android.graphics.RectF, com.geodroid.euclidian.EuclidianView)
	 */
	@Override
	protected void processMove(RectF touchedArea, EuclidianView view) {
		this.process(touchedArea, view) ;
		
	}



	/* (non-Javadoc)
	 * @see com.geodroid.action.Action#processUp(android.graphics.RectF, com.geodroid.euclidian.EuclidianView)
	 */
	@Override
	protected void processUp(RectF touchedArea, EuclidianView view) {
		// TODO Auto-generated method stub
		
	}



	/* (non-Javadoc)
	 * @see com.geodroid.action.Action#processDown(int, float, float, com.geodroid.euclidian.EuclidianView)
	 */
	@Override
	public void processDown(RectF touchedArea, EuclidianView view) {
		/*save the position*/
		oldTouchedArea = touchedArea ; 
	}

}
